package fr.uparis10.miage.m1p1.menu.project;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

import fr.uparis10.miage.m1p1.config.Configurator;
import fr.uparis10.miage.m1p1.core.Projet;
import fr.uparis10.miage.m1p1.global.LogFactory;
import fr.uparis10.miage.m1p1.menu.MenuExecutor;

public class ShowProjectExecutor implements MenuExecutor {
	private Logger log = LogFactory.getInstance().getLogger(
			ShowProjectExecutor.class.getName());

	public void execute() {
		// TODO ask the employee nr. and search it in the organization
		byte[] buf = new byte[100];
		System.out.print("Project name? (<EMPTY> - cancel): ");
		String projName;
		try {
			System.in.read(buf);
			projName = (new String(buf)).trim();
		} catch (IOException exc) {
			log.log(Level.SEVERE, "Ooops...", exc);
			return;
		}
		if (projName.length() == 0) {
			return;
		}
//		ObjectJ entr = Configurator.getInstance().getObjectJ();
		// TODO: change this logic to get everything from ObjectJ
		Projet proj = Configurator.getInstance().getProjetMap().get(projName);
		if (proj == null) {
			System.out.println("No such project");
			return;
		}
		System.out.println();
		System.out.println(proj);
	}

}
